package com.example.test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.example.test.bean.GW;
import com.example.test.util.ToastUtil;

public class GWActivity extends AppCompatActivity {
    private EditText carNumber,date_1,w_1;
    private MySQLiteOpenHelper_1 mySQLiteOpenHelper_1;
    String CarNumber,Date_1,W_1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gw);
        initView();
        mySQLiteOpenHelper_1 = new MySQLiteOpenHelper_1(this);
    }
    private void initView(){
        carNumber = findViewById(R.id.carNumber);
        date_1 = findViewById(R.id.date_1);
        w_1 = findViewById(R.id.w_1);
    }
    public void gw_btn(View view){
        CarNumber = carNumber.getText().toString();
        Date_1 = date_1.getText().toString();
        W_1 = w_1.getText().toString();

        GW gw =new GW();
        gw.setCarNumber(CarNumber);
        gw.setDate_1(Date_1);
        gw.setW_1(W_1);

        long rowId =mySQLiteOpenHelper_1.insertData(gw);
        if(rowId !=-1){
            ToastUtil.toastShort(this,"添加成功");
        }else {
            ToastUtil.toastShort(this,"添加失败");

        }
    }
}